package com.amtf.datafile2.core.std;

import com.amtf.datafile2.DataField;
import com.amtf.datafile2.DataFieldDefinition;
import com.amtf.datafile2.DataFieldParser;

public class StdDataFieldParser<T extends DataFieldDefinition> implements DataFieldParser {
	private T dfdef;

	public StdDataFieldParser(T dfdef) {
		this.dfdef = dfdef;
	}

	public DataField parse(String value) {
		DataField df = dfdef.newDataFieldInstance();
		df.setValue(value);
		return df;
	}

	public DataField parse(Object value) {
		DataField df = dfdef.newDataFieldInstance();
		df.setValue(value.toString());
		return df;
	}

	// public DataField parse(String value, DataField intoField) {
	// if (intoField == null) {
	// intoField = dfdef.newDataFieldInstance();
	// }
	// intoField.setValue(value);
	// return intoField;
	// }
	//
	// public DataField parse(Object value, DataField intoField) {
	// if (intoField == null) {
	// intoField = dfdef.newDataFieldInstance();
	// }
	// intoField.setValue(value.toString());
	// return intoField;
	// }

}
